﻿using System;
using System.Globalization;
using System.Text.Json;
using System.Windows.Data;

namespace AmiDraw.Editor.Converters
{
    public class ObjectToJsonConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return JsonSerializer.Serialize(value, new JsonSerializerOptions() { 
                Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping ,
                WriteIndented = true,
            
            });
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
